{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import pandas\n",
    "import os\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn\n",
    "from sklearn import model_selection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Attrition</th>\n",
       "      <th>DistanceFromHome</th>\n",
       "      <th>Education</th>\n",
       "      <th>EmployeeNumber</th>\n",
       "      <th>EnvironmentSatisfaction</th>\n",
       "      <th>JobInvolvement</th>\n",
       "      <th>JobLevel</th>\n",
       "      <th>JobSatisfaction</th>\n",
       "      <th>MonthlyIncome</th>\n",
       "      <th>...</th>\n",
       "      <th>RelationshipSatisfaction</th>\n",
       "      <th>StandardHours</th>\n",
       "      <th>StockOptionLevel</th>\n",
       "      <th>TotalWorkingYears</th>\n",
       "      <th>TrainingTimesLastYear</th>\n",
       "      <th>WorkLifeBalance</th>\n",
       "      <th>YearsAtCompany</th>\n",
       "      <th>YearsInCurrentRole</th>\n",
       "      <th>YearsSinceLastPromotion</th>\n",
       "      <th>YearsWithCurrManager</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.0</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>36.999091</td>\n",
       "      <td>0.161818</td>\n",
       "      <td>9.427273</td>\n",
       "      <td>2.922727</td>\n",
       "      <td>1028.157273</td>\n",
       "      <td>2.725455</td>\n",
       "      <td>2.730909</td>\n",
       "      <td>2.054545</td>\n",
       "      <td>2.732727</td>\n",
       "      <td>6483.620909</td>\n",
       "      <td>...</td>\n",
       "      <td>2.696364</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.788182</td>\n",
       "      <td>11.221818</td>\n",
       "      <td>2.807273</td>\n",
       "      <td>2.746364</td>\n",
       "      <td>7.011818</td>\n",
       "      <td>4.207273</td>\n",
       "      <td>2.226364</td>\n",
       "      <td>4.123636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.037230</td>\n",
       "      <td>0.368451</td>\n",
       "      <td>8.196694</td>\n",
       "      <td>1.022242</td>\n",
       "      <td>598.915204</td>\n",
       "      <td>1.098053</td>\n",
       "      <td>0.706366</td>\n",
       "      <td>1.107805</td>\n",
       "      <td>1.109731</td>\n",
       "      <td>4715.293419</td>\n",
       "      <td>...</td>\n",
       "      <td>1.095356</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.843347</td>\n",
       "      <td>7.825548</td>\n",
       "      <td>1.291514</td>\n",
       "      <td>0.701121</td>\n",
       "      <td>6.223093</td>\n",
       "      <td>3.618115</td>\n",
       "      <td>3.313830</td>\n",
       "      <td>3.597996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>18.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1009.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>30.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>504.250000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2924.500000</td>\n",
       "      <td>...</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>36.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1026.500000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4857.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>43.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>1556.500000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>8354.500000</td>\n",
       "      <td>...</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>7.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>60.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>29.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>2065.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>19999.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>40.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>37.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>17.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               Age    Attrition  DistanceFromHome    Education  \\\n",
       "count  1100.000000  1100.000000       1100.000000  1100.000000   \n",
       "mean     36.999091     0.161818          9.427273     2.922727   \n",
       "std       9.037230     0.368451          8.196694     1.022242   \n",
       "min      18.000000     0.000000          1.000000     1.000000   \n",
       "25%      30.000000     0.000000          2.000000     2.000000   \n",
       "50%      36.000000     0.000000          7.000000     3.000000   \n",
       "75%      43.000000     0.000000         15.000000     4.000000   \n",
       "max      60.000000     1.000000         29.000000     5.000000   \n",
       "\n",
       "       EmployeeNumber  EnvironmentSatisfaction  JobInvolvement     JobLevel  \\\n",
       "count     1100.000000              1100.000000     1100.000000  1100.000000   \n",
       "mean      1028.157273                 2.725455        2.730909     2.054545   \n",
       "std        598.915204                 1.098053        0.706366     1.107805   \n",
       "min          1.000000                 1.000000        1.000000     1.000000   \n",
       "25%        504.250000                 2.000000        2.000000     1.000000   \n",
       "50%       1026.500000                 3.000000        3.000000     2.000000   \n",
       "75%       1556.500000                 4.000000        3.000000     3.000000   \n",
       "max       2065.000000                 4.000000        4.000000     5.000000   \n",
       "\n",
       "       JobSatisfaction  MonthlyIncome  ...  RelationshipSatisfaction  \\\n",
       "count      1100.000000    1100.000000  ...               1100.000000   \n",
       "mean          2.732727    6483.620909  ...                  2.696364   \n",
       "std           1.109731    4715.293419  ...                  1.095356   \n",
       "min           1.000000    1009.000000  ...                  1.000000   \n",
       "25%           2.000000    2924.500000  ...                  2.000000   \n",
       "50%           3.000000    4857.000000  ...                  3.000000   \n",
       "75%           4.000000    8354.500000  ...                  4.000000   \n",
       "max           4.000000   19999.000000  ...                  4.000000   \n",
       "\n",
       "       StandardHours  StockOptionLevel  TotalWorkingYears  \\\n",
       "count         1100.0       1100.000000        1100.000000   \n",
       "mean            80.0          0.788182          11.221818   \n",
       "std              0.0          0.843347           7.825548   \n",
       "min             80.0          0.000000           0.000000   \n",
       "25%             80.0          0.000000           6.000000   \n",
       "50%             80.0          1.000000          10.000000   \n",
       "75%             80.0          1.000000          15.000000   \n",
       "max             80.0          3.000000          40.000000   \n",
       "\n",
       "       TrainingTimesLastYear  WorkLifeBalance  YearsAtCompany  \\\n",
       "count            1100.000000      1100.000000     1100.000000   \n",
       "mean                2.807273         2.746364        7.011818   \n",
       "std                 1.291514         0.701121        6.223093   \n",
       "min                 0.000000         1.000000        0.000000   \n",
       "25%                 2.000000         2.000000        3.000000   \n",
       "50%                 3.000000         3.000000        5.000000   \n",
       "75%                 3.000000         3.000000        9.000000   \n",
       "max                 6.000000         4.000000       37.000000   \n",
       "\n",
       "       YearsInCurrentRole  YearsSinceLastPromotion  YearsWithCurrManager  \n",
       "count         1100.000000              1100.000000           1100.000000  \n",
       "mean             4.207273                 2.226364              4.123636  \n",
       "std              3.618115                 3.313830              3.597996  \n",
       "min              0.000000                 0.000000              0.000000  \n",
       "25%              2.000000                 0.000000              2.000000  \n",
       "50%              3.000000                 1.000000              3.000000  \n",
       "75%              7.000000                 3.000000              7.000000  \n",
       "max             18.000000                15.000000             17.000000  \n",
       "\n",
       "[8 rows x 23 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pandas.read_table(filepath_or_buffer=\"./员工离职预测训练赛/pfm_train.csv\",sep=\",\")\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['No', 'Yes'], dtype=object)"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[\"OverTime\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "e:\\python3\\lib\\site-packages\\pandas\\core\\ops\\__init__.py:1115: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n",
      "  result = method(y)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "data.loc[data[\"Gender\"]==\"Female\",\"Gender\"]=1\n",
    "data.loc[data[\"Gender\"]==\"Male\",\"Gender\"]=0\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Attrition</th>\n",
       "      <th>BusinessTravel</th>\n",
       "      <th>Department</th>\n",
       "      <th>DistanceFromHome</th>\n",
       "      <th>Education</th>\n",
       "      <th>EducationField</th>\n",
       "      <th>EmployeeNumber</th>\n",
       "      <th>EnvironmentSatisfaction</th>\n",
       "      <th>Gender</th>\n",
       "      <th>...</th>\n",
       "      <th>RelationshipSatisfaction</th>\n",
       "      <th>StandardHours</th>\n",
       "      <th>StockOptionLevel</th>\n",
       "      <th>TotalWorkingYears</th>\n",
       "      <th>TrainingTimesLastYear</th>\n",
       "      <th>WorkLifeBalance</th>\n",
       "      <th>YearsAtCompany</th>\n",
       "      <th>YearsInCurrentRole</th>\n",
       "      <th>YearsSinceLastPromotion</th>\n",
       "      <th>YearsWithCurrManager</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>37</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>77</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1245</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>33</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>34</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>147</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1026</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1111</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 31 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Age  Attrition  BusinessTravel  Department  DistanceFromHome  Education  \\\n",
       "0   37          0               0           2                 1          4   \n",
       "1   54          0               2           2                 1          4   \n",
       "2   34          1               2           2                 7          3   \n",
       "3   39          0               0           2                 1          1   \n",
       "4   28          1               2           2                 1          3   \n",
       "\n",
       "   EducationField  EmployeeNumber  EnvironmentSatisfaction  Gender  ...  \\\n",
       "0               0              77                        1       0  ...   \n",
       "1               0            1245                        4       1  ...   \n",
       "2               0             147                        1       0  ...   \n",
       "3               0            1026                        4       1  ...   \n",
       "4               1            1111                        1       0  ...   \n",
       "\n",
       "   RelationshipSatisfaction  StandardHours  StockOptionLevel  \\\n",
       "0                         3             80                 1   \n",
       "1                         1             80                 1   \n",
       "2                         4             80                 0   \n",
       "3                         3             80                 1   \n",
       "4                         1             80                 2   \n",
       "\n",
       "   TotalWorkingYears TrainingTimesLastYear  WorkLifeBalance  YearsAtCompany  \\\n",
       "0                  7                     2                4               7   \n",
       "1                 33                     2                1               5   \n",
       "2                  9                     3                3               9   \n",
       "3                 21                     3                3              21   \n",
       "4                  1                     2                3               1   \n",
       "\n",
       "  YearsInCurrentRole YearsSinceLastPromotion  YearsWithCurrManager  \n",
       "0                  5                       0                     7  \n",
       "1                  4                       1                     4  \n",
       "2                  7                       0                     6  \n",
       "3                  6                      11                     8  \n",
       "4                  0                       0                     0  \n",
       "\n",
       "[5 rows x 31 columns]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
